<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<title>内部管理系统</title>
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<link rel="stylesheet" type="text/css"
	href="../../lib/bootstrap/css/bootstrap.css">
<link rel="stylesheet" type="text/css"
	href="../../stylesheets/theme.css">
<link rel="stylesheet"
	href="../../lib/font-awesome/css/font-awesome.css">
	
<script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<script src="../../js/init.js"></script>

<link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>	

<!-- <script src="../../lib/jquery.min.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js"></script>
<script src="../../lib/jquery.validate.min.js"></script>
<script src="../../lib/jquery.cookie.js"></script>
<script src="../../lib/messages_cn.js" type="text/javascript"></script>
<script src="../../js/init.js"></script>
<script src="../../lib/jquery.messager.js"></script>
<link rel="stylesheet" href="//apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css">
<script src="//apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> -->
<style type="text/css">
#container {
	height: 300px;
	width: 400px;
}

.fl {
	float: left
}

select {
	width: 130px;
}
.title{
	font-size:18px;
	font-weight:bold;
}
</style>
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="lib/html5.js"></script>
    <![endif]-->
</head>

<!--[if lt IE 7 ]> <body class="ie ie6"> <![endif]-->
<!--[if IE 7 ]> <body class="ie ie7 "> <![endif]-->
<!--[if IE 8 ]> <body class="ie ie8 "> <![endif]-->
<!--[if IE 9 ]> <body class="ie ie9 "> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<body class="">
	<!--<![endif]-->

	<div class="navbar"></div>
	<div class="common"></div>

	<div class="sidebar-nav"></div>

	<div class="content">
		<div class="well">
			<ul class="nav nav-tabs">
				<li class="active"><a href="#userlist" data-toggle="tab">企业</a></li>
			</ul>
			<div id="myTabContent" class="tab-content">

					<div class="container-fluid">
						<div class="span8">
							<form class="form-horizontal" id="user_form">
								<div class="control-group title">兼职岗位详情 </div>
									<input type="hidden" id="companyId">
									<input type="hidden" id="postId">
									<input type="hidden" id="postFlag">
									<input type="hidden" id="dicParttimeFieldId_hidden">
									<input type="hidden" id="dicSettlementId_hidden">
									<input type="hidden" id="hasAllowanceFlag_hidden">
									<input type="hidden" id="provinceId_hidden">
									<input type="hidden" id="cityId_hidden">
									<input type="hidden" id="districtId_hidden">
								<table class="table">
										<tr>
											<td><label class="control-label">岗位名称：</label></td>
											<td>
												<select name="dicParttimeFieldId" id="dicParttimeFieldId"></select>
											</td>
											<td><label class="control-label">招聘人数：</label></td>
											<td>
												<input type="text"  id="recruitingNumbers" name="recruitingNumbers" placeholder="招聘人数">
											</td>
										</tr>
										<tr>
											<td><label class="control-label">工资：</label></td>
											<td>
												<input class="input-mini" type="text"  id="salaryNum" name="salaryNum" placeholder="工资">
												／
												<input class="input-mini" type="text"  id="unit" name="unit" placeholder="单位">
											</td>
											<td><label class="control-label">结算方式：</label></td>
											<td>
												<select name="dicSettlementId" id="dicSettlementId"></select>
											</td>
										</tr>
										<tr>
											<td><label class="control-label">工作日期：</label></td>
											<td>
												<input class="input-mini" type="text" id="startData"  placeholder="MM/dd/yyyy">
												－
												<input class="input-mini" type="text" id="endData"  placeholder="MM/dd/yyyy">
											</td>
											<td><label class="control-label">工作时间：</label></td>
											<td>
												<input class="input-mini" type="text" id="startTime"  placeholder="HH:mm">
												－
												<input class="input-mini" type="text" id="endTime"  placeholder="HH:mm">
											</td>
										</tr>
										<tr>
											<td><label class="control-label">有无补贴：</label></td>
											<td>
												<input name="hasAllowanceFlag" type="radio" value="1" />有
												<input name="hasAllowanceFlag" type="radio" value="0" />没有
											</td>
											<td><label class="control-label">地区：</label></td>
											<td>
												<select name="provinceId" id="provinceId" onchange="loadCity()"></select>
												<select name="cityId" id="cityId" onchange="loadDistrict()"></select>
												<select name="districtId" id="districtId"></select>
											</td>
										</tr>
										<tr>
											<td><label class="control-label">地址：</label></td>
											<td>
												<input type="text"  id="location" name="location" placeholder="地址">
											</td>
											<td><label class="control-label">简介：</label></td>
											<td>
												<input type="text"  id="description" name="description" placeholder="简介">
											</td>
										</tr>
										<tr>
											<td><label class="control-label">岗位要求：</label></td>
											<td>
												<input type="text"  id="requirement" name="requirement" placeholder="岗位要求">
											</td>
											<td><label class="control-label">截止日期：</label></td>
											<td>
												<input type="text" id="deadlineExtra"  placeholder="MM/dd/yyyy">
											</td>
										</tr>
										<tr>
											<td><label class="control-label">电话：</label> </td>
											<td>
												<input type="text"  id="tel" name="tel" placeholder="电话">
											</td>
											<td></td>
											<td></td>
										</tr>
								</table>

								<div class="form-actions">
									<button id="btn-back" type="button" class="btn ">返回</button>
									<button id="btn-save" type="button" class="btn ">保存</button>
								</div>

							</form>
						</div>
					</div>
										<div class="tab-pane active in" id="userlist">

					
				</div>
			</div>
		</div>
	</div>


	<script type="text/javascript">
	
		//初始化导航栏
		$(function() {
			initAdminNavBar();
			initCommon();
			initSideBar('user-management', 'company-list');
			$("#startData").datepicker();
			$("#endData").datepicker();
			$("#deadlineExtra").datepicker();
			
			reloadtable();

			$('#btn_jump').on('click', function(e) {
				reloadtable();
			});

			$('#btn_next').on('click', function(e) {
				var curpage = $('#list_page').val();
				$('#list_page').val(parseInt(curpage) + 1);
				reloadtable();
			});

			$('#btn_prev').on('click', function(e) {
				var curpage = $('#list_page').val();
				if (parseInt(curpage) > 1) {
					$('#list_page').val(parseInt(curpage) - 1);
					reloadtable();
				}
			});
		});
		
		
		//初始化页面信息
		function onload(){
			var postId = getparastr('postId');
			var postFlag = getparastr('postFlag');
			var companyId = getparastr('companyId');
			$("#postId").val(postId);
			$("#postFlag").val(postFlag);
			$("#companyId").val(companyId);
			
			var hasAllowanceFlag_hidden = $('#hasAllowanceFlag_hidden').val();
			if(hasAllowanceFlag_hidden != null && hasAllowanceFlag_hidden != ""){
				if(hasAllowanceFlag_hidden == 0){
					$(":radio[name=hasAllowanceFlag][value=1]").attr("checked",false);
					$(":radio[name=hasAllowanceFlag][value=0]").attr("checked",true);
				}else if(hasAllowanceFlag_hidden == 1){
					$(":radio[name=hasAllowanceFlag][value=1]").attr("checked",true);
					$(":radio[name=hasAllowanceFlag][value=0]").attr("checked",false);
				}else{
					$(":radio[name=hasAllowanceFlag][value=1]").attr("checked",false);
					$(":radio[name=hasAllowanceFlag][value=0]").attr("checked",true);	
				}
			}else{
				$(":radio[name=hasAllowanceFlag][value=1]").attr("checked",false);
				$(":radio[name=hasAllowanceFlag][value=0]").attr("checked",true);	
			}
			
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectParttimeField.json",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicFieldId
									+ "'>" + data.responseData[int].dicFieldName
									+ "</option> ";
						}
						$('#dicParttimeFieldId').html(options);
						var dicParttimeFieldId_hidden = $('#dicParttimeFieldId_hidden').val();
						$("#dicParttimeFieldId").val(dicParttimeFieldId_hidden);
					}
				}
			});
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectSettlement.json",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicSettlementId
									+ "'>" + data.responseData[int].dicSettlementName
									+ "</option> ";
						}
						$('#dicSettlementId').html(options);
						var dicSettlementId_hidden = $('#dicSettlementId_hidden').val();
						$("#dicSettlementId").val(dicSettlementId_hidden);
					}
				}
			});
			$.ajax({
				contentType : "application/json",
				url : api_base_url1
						+ "open/dic/selectDistrictList.json?level=1",
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						var options = "<option value='0'>请选择</option>";

						for (var int = 0; int < data.responseData.length; int++) {
							options += "<option value='" + data.responseData[int].dicDistrictId
									+ "'>" + data.responseData[int].dicDistrict
									+ "</option> ";
						}
						$('#provinceId').html(options);
						var provinceId_hidden = $('#provinceId_hidden').val();
						$("#provinceId").val(provinceId_hidden); 
					}
				}
			});
			var provinceId_hidden = $('#provinceId_hidden').val();
			if(provinceId_hidden != null && provinceId_hidden != ""){
				loadCity(provinceId_hidden);
			}
			var cityId_hidden = $('#cityId_hidden').val();
			if(cityId_hidden != null && cityId_hidden != ""){
				loadDistrict(cityId_hidden);
			}
		}
		
		function loadCity(provinceId_hidden){
			var provinceId = $('#provinceId').val();
			if(provinceId == null || provinceId == ""){
				provinceId = provinceId_hidden;
			}
		     $("#cityId").empty();
		     $("#districtId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=2&parentId=" + provinceId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#cityId').html(options);
							var cityId_hidden = $('#cityId_hidden').val();
							$("#cityId").val(cityId_hidden);
						}
					}
				});
		}
		
		function loadDistrict(cityId_hidden){
			var cityId = $('#cityId').val();
			if(cityId == null || cityId == ""){
				cityId = cityId_hidden;
			}
		     $("#districtId").empty();
		     $.ajax({
					contentType : "application/json",
					url : api_base_url1
							+ "open/dic/selectDistrictList.json?level=3&parentId=" + cityId,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var options = "<option value='0'>请选择</option>";

							for (var int = 0; int < data.responseData.length; int++) {
								options += "<option value='" + data.responseData[int].dicDistrictId
								+ "'>" + data.responseData[int].dicDistrict
										+ "</option> ";
							}
							$('#districtId').html(options);  
							var districtId_hidden = $('#districtId_hidden').val();
							$("#districtId").val(districtId_hidden);
						}
					}
				});
		}
		
		//初始化用户详细信息
		function reloadtable() {
			var postId = getparastr('postId');
			var postFlag = getparastr('postFlag');
			if (postId != null && postId != "" && postFlag != null && postFlag != "") {//更新的情况下,给页面赋初始值
				$.ajax({
					contentType : "application/json",
					url : api_base_url
							+ "selectPostDetail.json?postId="
							+ postId + "&postFlag=" + postFlag,
					dataType : "json",
					success : function(data) {
						if (data.code == "200") {
							var dicParttimeFieldId = data.responseData.dicParttimeFieldId;
							var recruitingNumbers = data.responseData.recruitingNumbers;
							var dicSettlementId = data.responseData.dicSettlementId;
							var hasAllowanceFlag = data.responseData.hasAllowanceFlag;
							var salaryNum = data.responseData.salaryNum;
							var unit = data.responseData.unit;
							var startDate = data.responseData.startDate;
							var endDate = data.responseData.endDate;
							var startTime = data.responseData.startTime;
							var endTime = data.responseData.endTime;
							var provinceId = data.responseData.provinceId;
							var cityId = data.responseData.cityId;
							var districtId = data.responseData.districtId;
							var location = data.responseData.location;
							var description = data.responseData.description;
							var deadlineExtra = data.responseData.deadlineExtra;
							var requirement = data.responseData.requirement;
							var tel = data.responseData.tel;
							$("#dicParttimeFieldId_hidden").val(dicParttimeFieldId);
							$("#recruitingNumbers").val(recruitingNumbers);
							$("#dicSettlementId_hidden").val(dicSettlementId);
							$("#hasAllowanceFlag_hidden").val(hasAllowanceFlag);
							$("#salaryNum").val(salaryNum);
							$("#unit").val(unit);
							$("#startData").val(startDate);
							$("#endData").val(endDate);
							$("#startTime").val(startTime);
							$("#endTime").val(endTime);
							$("#provinceId_hidden").val(provinceId);
							$("#cityId_hidden").val(cityId);
							$("#districtId_hidden").val(districtId);
							$("#location").val(location);
							$("#description").val(description);
							$("#deadlineExtra").val(deadlineExtra);
							$("#requirement").val(requirement);
							$("#tel").val(tel);
							
							onload();
						}
						$.messager.anim('fade', 1000);
					    $.messager.show('操作提示',data.msg, 5000);
					}
				});
			}  else{
				onload();
			}

		}


		//返回
		$('#btn-back').on('click', function() {
			history.back()
		});
		
		//保存
		$('#btn-save').on('click', function() {
			var postId = $('#postId').val();
			var postFlag = $('#postFlag').val();
			var companyId = $('#companyId').val();
			
			var dicParttimeFieldId = $("#dicParttimeFieldId").val();
			var recruitingNumbers = $("#recruitingNumbers").val();
			var dicSettlementId = $("#dicSettlementId").val();
			var hasAllowanceFlag = $("input[name='hasAllowanceFlag']:checked").val();
			var salaryNum = $("#salaryNum").val();
			var unit = $("#unit").val();
			var startDate = $("#startData").val();
			var endDate = $("#endData").val();
			var startTime = $("#startTime").val();
			var endTime = $("#endTime").val();
			var districtId = $("#districtId").val();
			var location = $("#location").val();
			var description = $("#description").val();
			var deadlineExtra = $("#deadlineExtra").val();
			var requirement = $("#requirement").val();
			var tel = $("#tel").val();
			
			$.ajax({
				contentType : "application/json",
				url : api_base_url
						+ "saveParttimeDetail.json?postId=" + postId
						+ "&companyId=" + companyId
						+ "&dicParttimeFieldId=" + dicParttimeFieldId
						+ "&dicSettlementId=" + dicSettlementId
						+ "&hasAllowance=" + hasAllowanceFlag
						+ "&salary=" + salaryNum
						+ "&unit=" + unit
						+ "&startDate=" + startDate
						+ "&endDate=" + endDate
						+ "&startTime=" + startTime
						+ "&endTime=" + endTime
						+ "&recruitingNumbers=" + recruitingNumbers
						+ "&districtId=" + districtId
						+ "&location=" + location
						+ "&description=" + description
						+ "&requirement=" + requirement
						+ "&deadline=" + deadlineExtra
						+ "&tel=" + tel,
				dataType : "json",
				success : function(data) {
					if (data.code == "200") {
						window.location.href="../usermanagement/parttimelist.html?companyId=" + companyId;
					}else{
						$.messager.anim('fade', 1000);
					    $.messager.show('操作提示',data.msg, 5000);
					}
					
				}
			});
		});



	</script>

</body>
</html>


